<!DOCTYPE html>
<html>
{include file="users/public_layout" /}
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15>
                    <div class="layui-form" wid100 lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><b>*</b>置顶天数</label>
                            <div class="layui-input-inline">
                                <input type="text" name="num" value="1" lay-verify="required|number" class="layui-input">
                                <div class="layui-form-inline2">复制到的目标栏目必须和当前模型类型一致，否则程序会自动忽略不符合的文档。</div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <input type="hidden" name="aid" id="aid" value="{$aid}">
                                    <input type="hidden" name="type" id="type" value="{$type}">
                                    <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <script>
            layui.config({
                base: '__SKIN__/' //静态资源所在路径
                ,version: '{$version}'
            }).extend({
                index: 'lib/index' //主入口模块
            }).use(['index', 'set'], function(){
                var $ = layui.$
                    ,layer = layui.layer
                    ,form = layui.form;

                var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                //监听提交
                form.on('submit(formSubmit)', function(data){
                    var load = layer_loading();
                    data.field._ajax = 1;
                    $.ajax({
                        type : 'post',
                        url : "{$form_action|default=''}",
                        data : data.field,
                        dataType : 'json',
                        success : function(res){
                            layer.close(load); //关闭loading
                            if(res.code == 1){
                                parent.layer.msg(res.msg, {shade: 0.3, time: 1000}, function(){
                                    parent.window.location.reload();
                                    parent.layer.close(parentObj);
                                });
                            }else{
                                showErrorMsg(res.msg);
                            }
                        },
                        error: function(e){
                            layer.close(load); //关闭loading
                            showErrorAlert();
                        }
                    });
                    return false;
                });
            });
        </script>
    </body>
</html>